package com.wzb.mybatisplus.bitaction.electrumaction.five;

import com.wzb.mybatisplus.bitaction.electrumaction.four.WIFPrivateKeyConverter;
import org.bitcoinj.core.*;
import org.bitcoinj.params.MainNetParams;
import java.math.BigInteger;

public class WIFToPrivateKey {

    private static final NetworkParameters params = MainNetParams.get();

    public static void main(String[] args) {
        // 测试私钥（请勿使用真实资产私钥）
        String[] testKeys = {
                "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ", // 以5开头（非压缩）
                "L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1", // 以L开头（压缩）
                "KwdMAjGmerYanjeui5SHS7JkmpZvVipYvB2LJGU1ZxJwYvP98617"  // 以K开头（压缩）
        };

        for (String wifKey : testKeys) {
            try {
                System.out.println("=== 转换 WIF 私钥 ===");
                System.out.println("WIF格式: " + wifKey);

                WIFPrivateKeyConverter.ConversionResult result =
                        WIFPrivateKeyConverter.convertWIFToHexAndDecimal(wifKey);

                System.out.println("十六进制: " + result.getHex());
                System.out.println("十进制: " + result.getDecimal());
                System.out.println("长度 - Hex: " + result.getHex().length() + " chars");
                System.out.println("长度 - Decimal: " + result.getDecimal().length() + " digits");
                System.out.println();

            } catch (Exception e) {
                System.err.println("转换失败: " + e.getMessage());
                e.printStackTrace();
            }
        }
    }
}
